//
//  BaseTableViewController.swift
//  WeiBo001
//
//  Created by Zhanghong on 15/6/27.
//  Copyright © 2015年 HeiMa. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    var userlogin = true
    var visitorView : VisitorLoginView?
    
    override func loadView() {
        userlogin = shareAccount != nil
       print("用户登录\(userlogin)")
        userlogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }
    
    private func setupVisitorView(){
        visitorView = VisitorLoginView()
        // 设置代理 
        visitorView?.delegate = self
        view = visitorView!
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClick")
    }
    
    func visitorRegisterButtonClick() {
        print("注册");
    }
    
    func visitorLoginButtonClick() {
//        print("登录")
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: false, completion: nil)
    }
    
    
    
    

}
